import java.util.*;

/**
 * @author LKQ
 * @date 2022/7/8 9:31
 * @description 枚举每个位置，然后判断最小代价
 */
public class Solution {
    public static void main(String[] args) {

    }
    public int minCostToMoveChips(int[] position) {
        Set<Integer> set = new HashSet<>();
        for (int a: position) {
            set.add(a);
        }
        long minCost = Long.MAX_VALUE;
        // 枚举每个最终位置
        for (int a: set) {
            long cost = 0;
            for (int b: position) {
                if (Math.abs(a - b) % 2 == 1) {
                    cost++;
                }
            }
            if (cost < minCost) {
                minCost = cost;
            }
        }
        return (int) minCost;
    }
}
